package com.cuotibao.zhuoxiao.basics.utils;

import android.text.TextUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static java.util.regex.Pattern.compile;

/**
 * @author hdx on 2019/5/6.
 */
public class ClassPathResource {
    public static boolean isMobileNO(String mobiles) {
        String telRegex = "^[1][23456789]\\d{9}$";
        if (TextUtils.isEmpty(mobiles)) return false;
        else return mobiles.matches(telRegex);
    }

    public static boolean isEmail(String email) {
        String str = "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$";
        Pattern p = compile(str);
        Matcher m = p.matcher(email);
        return m.matches();
    }

    public static boolean isPassWordCorrect(String password) {
        return !TextUtils.isEmpty(password) && password.length() > 6 && password.length() < 16;

    }

    public static boolean isStringEmpty(String password) {
        return TextUtils.isEmpty(password);

    }

    public static boolean isPassWordSetCorrect(String password, String repassword) {
        return password.equals(repassword);

    }

    public static boolean isNumeric(String str) {
        if ("".equals(str)) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            System.out.println(str.charAt(i));
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }
}
